package com.homework.ch08;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Random;
public class Test4 {
    public static void main(String[] args) {
        List<Integer> list1=new ArrayList<>();
        List<Integer> list2=new ArrayList<>();
        Random random=new Random();
        for (int i = 0; i < 20; i++) {
            list1.add(random.nextInt(20)+1);
        }
        System.out.println(list1);
        for(Integer num:list1)
        {
            if(num%2==0)
            {
                list2.add(num);
            }
        }
        //System.out.println(list2);
        Iterator it=list2.iterator();
        while(it.hasNext())
        {
            System.out.print(it.next()+" ");
        }
    }
}
